﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jquery-validation-demo.aspx.cs" Inherits="register_jquery_validation_demo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JQUERY Validation Test</title>

    <script src="js/jquery.js" type="text/javascript"></script> 
    <script src="js/jquery.validate.min.js" type="text/javascript"></script> 
    <script src="js/messages_de.js" type="text/javascript"></script> 


    <script type="text/javascript">

        $(document).ready(function () {

            //validateForm();

            $("#submitRegistration").click(function (e) {

                e.preventDefault();
                alert("We're in!");
                validateForm();

                alert($("#registration_form").valid());

            });
        });


        function validateForm() {
            $("#registration_form").validate({

                rules: {

                    privacy: {
                        required: true
                    }

                }
            });
        }
            

        function clearText(field) {
            if (field.defaultValue == field.value) {
                field.value = '';
            } else if (field.value == '') {
                field.value = field.defaultValue;
            }
        }

    </script>

</head>
<body>

    <form id="registration_form" runat="server">
        <input name="fname" type="text" value="First Name" onfocus="clearText(this)" onblur="clearText(this)" />
        <br />
        <input name="lname" type="text" value="Last Name"/>
        <br />
        <input name="email" type="text" value="E-Mail"/>
        <br />
        <input name="privacy" type="checkbox"/>
        <br />

        <div class="error">
        </div>

        <br />

        <input type="submit" />    
        <a id="submitRegistration" href="">Submit</a>
    </form>

</body>
</html>
